package com.twu.biblioteca;

/**
 * Created with IntelliJ IDEA.
 * User: mini server
 * Date: 9/20/13
 * Time: 3:32 AM
 * To change this template use File | Settings | File Templates.
 */
public class AllBooksView implements IView{

    private Library library;
    public static final String WELCOME_MESSAGE = "List of all the books:" + "\n";

    public AllBooksView()
    {
        library = Library.GetInstanceOfLibrary(Library.OLD_INSTANCE);
    }

    public AllBooksView(int code) // A constructor useful for testing or resetting view.
    {
        library = Library.GetInstanceOfLibrary(code);
        if (library == null)
        {
            throw new IllegalArgumentException("Unknown Library Code " + code);
        }
    }

    public AllBooksView(Library library)
    {
        this.library = library;
    }

    @Override
    public String display() {
        return WELCOME_MESSAGE + library.list(Inventory.BOOK_INVENTORY);
    }

    @Override
    public IView interact() {
        return new MenuView();
    }
}
